package cn.net.wanji.utils;

import com.alibaba.fastjson.*;
import java.util.*;

public class JsonParserUtils {
    public static List<JSONObject> parseRsuHeartbeatList(String jsonString) {
      /*  List<JSONObject> rsuHeartbeatList = new ArrayList<>();*/

        JSONObject jsonObject = JSON.parseObject(jsonString);
        JSONObject value = jsonObject.getJSONObject("Value");
        String valueString = value.getString("antennaInfoList");
        JSONArray rsuHeartbeatList = JSONArray.parseArray(valueString);
        Object o = rsuHeartbeatList.get(0);
        JSONObject jsonObject1 = JSON.parseObject(String.valueOf(o));

        System.out.println(jsonObject1);
        /*JSONArray rsuHeartbeatArray = valueJson.getJSONArray("rsuHeartbeatList");

        for (int i = 0; i < rsuHeartbeatArray.size(); i++) {
            JSONObject rsuHeartbeat = rsuHeartbeatArray.getJSONObject(i);
            rsuHeartbeatList.add(rsuHeartbeat);
        }
*/
        return null;
    }

    public static void main(String[] args) {
        String jsonString = "{\"Identity\":\"2023-12-27T15:59:32\",\"Url\":\"receive/deviceStatusData\",\"Headers\":null,\"Value\":\"{\\\"gantryId\\\":\\\"S001933030055210017\\\",\\\"createTime\\\":\\\"2023-12-27T15:59:32\\\",\\\"controllerHeartbeatList\\\":[{\\\"deviceId\\\":\\\"1\\\",\\\"stateTime\\\":\\\"2023-12-27T15:59:32\\\",\\\"brand\\\":\\\"wanji\\\",\\\"deviceType\\\":\\\"WE90\\\",\\\"deviceSn\\\":\\\"WJ2112918\\\",\\\"connectStatus\\\":\\\"1\\\",\\\"workStatus\\\":\\\"1\\\",\\\"statusCode\\\":\\\"0\\\",\\\"statusMsg\\\":\\\"正常\\\",\\\"cpuOccupy\\\":\\\"43.67%%\\\",\\\"memOccupy\\\":\\\"60.96%%\\\",\\\"memTotal\\\":\\\"15\\\",\\\"flashOccupy\\\":\\\"15%\\\",\\\"flashTotal\\\":\\\"469G\\\"}],\\\"cameraHeartbeatList\\\":[{\\\"deviceId\\\":\\\"1\\\",\\\"stateTime\\\":\\\"2023-12-27T15:58:30\\\",\\\"laneNum\\\":\\\"1\\\",\\\"brand\\\":\\\"海康\\\",\\\"deviceType\\\":\\\"IP CAPTURE CAMERA\\\",\\\"deviceSn\\\":\\\"\\\",\\\"connectStatus\\\":\\\"1\\\",\\\"workStatus\\\":\\\"1\\\",\\\"lightWorkStatus\\\":\\\"1\\\",\\\"statusCode\\\":\\\"0\\\",\\\"statusMsg\\\":\\\"正常\\\"}],\\\"laserHeartbeatList\\\":[],\\\"rsuHeartbeatList\\\":[\\\"{\\\\\\\"deviceId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"stateTime\\\\\\\":\\\\\\\"2023-12-27T15:59:24\\\\\\\",\\\\\\\"brand\\\\\\\":\\\\\\\"wanji\\\\\\\",\\\\\\\"deviceType\\\\\\\":\\\\\\\"WER13-01F\\\\\\\",\\\\\\\"sn\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"connectStatus\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"workStatus\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"statusCode\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"statusMsg\\\\\\\":\\\\\\\"正常\\\\\\\",\\\\\\\"controlNetWork\\\\\\\":\\\\\\\"2\\\\\\\"}\\\",\\\"{\\\\\\\"deviceId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"statusTime\\\\\\\":\\\\\\\"2023-12-27T15:59:24\\\\\\\",\\\\\\\"brand\\\\\\\":\\\\\\\"wanji\\\\\\\",\\\\\\\"deviceType\\\\\\\":\\\\\\\"WER13-01F\\\\\\\",\\\\\\\"sn\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"connectStatus\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"workStatus\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"statusCode\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"statusMsg\\\\\\\":\\\\\\\"正常\\\\\\\",\\\\\\\"controlNetWork\\\\\\\":\\\\\\\"2\\\\\\\"}\\\"],\\\"antennaInfoList\\\":[{\\\"deviceId\\\":\\\"1\\\",\\\"status\\\":\\\"113011\\\"},{\\\"deviceId\\\":\\\"2\\\",\\\"status\\\":\\\"1\\\"},{\\\"deviceId\\\":\\\"3\\\",\\\"status\\\":\\\"1\\\"}]}\",\"Files\":null,\"FileList\":null,\"SendMode\":0}";

        List<JSONObject> rsuHeartbeatList = parseRsuHeartbeatList(jsonString);

        for (JSONObject rsuHeartbeat : rsuHeartbeatList) {
            System.out.println("rsuHeartbeatList item: " + rsuHeartbeat);
        }
    }
}
